<%-- 
    Document   : formEmpIntervenant
    Created on : 26 févr. 2013, 12:17:01
    Author     : ali
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="EDT.obj.Intervenant"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                
        <title>Emplois du temps Intervenant form</title>
            <link rel="stylesheet" href="Accueil.css" />
            <link rel="SHORTCUT ICON" href="./edt.jpg" />
    </head>


    <body>    
         
    <section>
      

        

        
         
    <!--<form method='POST' action='PromoNivGradForm.do'> -->
   <%
    String form ="";
    
    ArrayList<Intervenant> intervenant = new ArrayList<Intervenant>();
    
    
    if(session.getAttribute("intervenant") == null || request.getParameter("intervenant")==null){
        
         //intervenant = EDT.api.API.getAllIntervenant(null);
        intervenant = EDT.api.API.getIntervenant();
        
        form += "<form method='POST' action='ConsultEmploiIntervenant.do' target='section'>";
        form += "<div class='commentaire'>";
        form += "<fieldset>";
        
        
        form +="<legend>    Choisissez un intervenant  :   </legend>";
        form +="Intervenant : <select name='intervenant'>";
        for (Intervenant i : intervenant)
        form +="    <option value='"+i.getId()+"'>"+i.getPrenom()+" "+i.getNom()+"</option>";
        form +="</select><br/><br/>";
        
        session.setAttribute( "intervenant", intervenant );
        
               }else{
        
        intervenant = (ArrayList<Intervenant> ) session.getAttribute("intervenant");
        form +="<form method='POST' action='IntervEmp.do' target='section'>\n";
        form += "<div class='commentaire'>\n";
        form += "<fieldset>";
        
        
        form += "<legend>    Choisissez une année  :   </legend>";
        
        int s = Integer.parseInt(request.getParameter("intervenant"));
        form += "<input type='hidden' name='intervenant' value='"+s+"'/>"; 
        
        form += "Annee : <select name='annee'>";
        
        String nom ="";
        String prenom="";
        
        for (Intervenant k : intervenant){
            
            if (s == k.getId() ){
                nom = k.getNom();
                prenom = k.getPrenom();
                for (int j = k.getAnneea(); j<= k.getAnneeb(); j++){
                    
                    form += "<option value='"+j+"'>"+j+"/"+(j+1)+"</option>";
                    
                }
                     
            }               
        }
        form += "</select><br/><br/>";
        form += "<input type='hidden' name='nom' value='"+nom+"'/>";
        form +="<input type='hidden' name='prenom' value='"+prenom+"'/>";
            //out.println(form);
            
        session.removeAttribute("intervenant");
                       
               }
    
        form +="<input type='submit' value='valider'/><br/>";
        out.println(form);
            
    %>
    
   
    
    
    <html:errors/> 
    
    </fieldset>
    
        
    </div>

    </form>
         
    </section>
    </body>
</html>
